<template>
  <div class="app-container">
    <eHeader :param-bean="paramBean" :sup_this="sup_this" />
    <eForm ref="form" :sup_this="sup_this" />
    <!--表格渲染-->
    <DataGridTable
      v-loading="loading"
      ref="mainTable"
      :sup_this="sup_this"
      :data="data.rtnList"
      :total="total"
      :show-cell-class="true"
      :show-row-complex-number="true"
      :all-define-columns="['reportCode','reportName','reportSort','selfStateName','attribute1','lastUpdateDate']"
      grid-id="sysPrintMngMainGridId"
      @toViewHistory="toViewHistory"
      @selection-change="handleGridSelectionChange">
      <el-table-column :show-overflow-tooltip="true" prop="funProcessName" label="业务类型" width="150px">
        <template slot-scope="scope">
          <edit :data="scope.row" :sup_this="sup_this" />
        </template>
      </el-table-column>
      <el-table-column slot="reportCode" prop="reportCode" label="系统报表" >
        <template slot-scope="scope">
          <div v-for="item in dicts.report_print_type" :key="item.id">
            <span v-if="scope.row.reportCode.toString() === item.dictCode">{{ item.dictName }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column slot="reportName" prop="reportName" label="打印模板名称" />
      <el-table-column slot="reportSort" prop="reportSort" align="center" width="50px" label="排序"/>
      <el-table-column slot="selfStateName" prop="selfStateName" label="状态"/>
      <el-table-column slot="attribute1" prop="attribute1" align="center" width="120px" label="附档">
        <template slot-scope="scope">
          <a title="下载" @click="downloadAttachment(scope.row)">{{ scope.row.attribute1 }}</a>
        </template>
      </el-table-column>
      <el-table-column slot="lastUpdateDate" prop="lastUpdateDate" label="更新日期">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdateDate) }}</span>
        </template>
      </el-table-column>
    </DataGridTable>
    <historyList ref="historyList" :sup_this="sup_this" />
  </div>
</template>

<script>
import { parseTime } from '@/utils/index'
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { loadDataUrl } from '@/api/system/sysPrint'
import eHeader from './module/header'
import eForm from './module/form'
import edit from './module/edit'
import historyList from './module/historyList'
import { downloadAttachment } from '@/api/system/fileMng'

export default {
  components: { eHeader, edit, eForm, historyList },
  mixins: [initData],
  dictTypes: ['report_print_type'],
  data() {
    return {
      sup_this: this
    }
  },
  created() {
    this.url = loadDataUrl()
    this.$nextTick(() => {
      this.init()
    })
  },
  methods: {
    parseTime,
    checkPermission,
    beforeInit() {
      return true
    },
    toViewHistory(row) {
      this.openViewHistory(row, 'historyList')
    },
    downloadAttachment(row) {
      downloadAttachment(row.attachmentPath, row.attribute1)
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss">
  .role-span {
    font-weight: bold;color: #303133;
    font-size: 15px;
  }
</style>
